package com;

import java.util.Properties;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

public class SendMail {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		Properties props =new Properties();
		Session session =Session.getInstance(props,null);
		props.put("mail.host", "127.0.0.1");
		props.put("mail.transport.protocol", "smtp");
		
		Message message = new MimeMessage(session);
		try {
			message.setFrom(new InternetAddress("liuwei8809@163.com"));
			message.setRecipient(Message.RecipientType.TO, new InternetAddress("zhangliguo_china@sina.com"));
			message.setSubject("你好吗？");
			message.setText("JavaMail发送邮件测试。");
			Transport.send(message);
		} catch (AddressException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (MessagingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
